<?php

include_once F_SOURCE . 'op/op.model.class.php';

/**
 * 操作日志管理
 * 
 * @author Dean
 *
 */
class opCtrl extends Ctrl{
	
	public function show(){
		$view = new View();
	
		$pageIndex = ($_GET['pageIndex']=='' || $_GET['pageIndex']<1)?1:$_GET['pageIndex'];
	
		$params = $this->getShowParams();
	
		$opModel = new opModel();
		$number = $opModel->countAll($params);
		$opList = $opModel->findAll(($pageIndex-1)*PageNum, PageNum, $params);
	
		$page = pageCount($number, $pageIndex, '?do=op.show');
	
		$data = array(
				'op_select' => 'op',
				'child_select' => 'show',
				'opList' => $opList,
				'page' => $page,
				'params'=>$params
		);
	
		$view->display($data, 'op-list.html');
	}
	
	/**
	 * 新增op投放操作
	 */
	public function add(){
	
		if (isset($_GET['do'])) {
			$do = explode('.', $_GET['do']);
		} else {
			$do = explode('.', DEFAULT_DO);
		}
	
		$time = getNowTime();
		$createUser = $_SESSION['ads']['user']->id;
	
		$data = array(
				'model' => $do[0],
				'action' => $do[1],
				'creater' => $createUser,
				'time' => $time,
		);
	
		$opModel = new opModel();
		$insertID = $opModel->add($data);
	}
}